﻿namespace Controllers
{
    using CompareFiles;
    using System.Diagnostics;

    /// <summary>
    /// Static Class for scripts execution
    /// </summary>
    public static class ScriptsExecution
    {
        /// <summary>
        /// Method for executing compare script
        /// </summary>
        /// <param name="path">Path of the application - parent folder</param>
        /// <param name="firstparam">First file for compare</param>
        /// <param name="secondparam">Second file for compare</param>
        /// <returns>ComparedFiles object</returns>
        public static void ExecCompareScript(string path, string firstparam, string secondparam, string thirdparam)
        {
            string comparepath = path + "Scripts\\CompareScript.txt";

            string param = " /closescript @\"" + comparepath + "\"" + " " + "\"" + firstparam + "\"" + " " + "\"" + secondparam + "\"" + " " + "\"" + thirdparam + "\"";

            Process.Start(beyondpath, param);
        }

        public static void ExecMergeScript(string path, string leftfile, string rightfile, string ancestorfile, string mergefile)
        {
            string mergepath = path + "Scripts\\MergeCommands.bat";

       //     string param = leftfile + " " + rightfile + " " + ancestorfile + " " + mergefile;

            string param = " /automerge /sync /closescript /fv=\"Text Merge\" /nobackups" + leftfile + " " + rightfile + " " + ancestorfile + " /mergeoutput=" + mergefile;

            Process.Start(beyondpath, param);
        }

        /// <summary>
        /// The hole path to Beyond Compare Program
        /// </summary>
        public static string beyondpath = @"C:\Program Files\Beyond Compare 3\BCompare.exe";
    }
}
